package com.xpgk.mvc.measurement;

import com.jfinal.plugin.activerecord.Model;
import com.xpgk.annotation.Table;
import com.xpgk.mvc.base.BaseModel;

/**
 * 标准体重表
 * */

@SuppressWarnings("unused")
@Table(tableName = StdWeightModel.table_name)
public class StdWeightModel extends BaseModel<StdWeightModel>{
	
	private static final long serialVersionUID = 1L;
	 public final static StdWeightModel me = new StdWeightModel();
	 
	 /**
		 * 表名称
		 */
		public static final String table_name = "sb_customer_std_weight";

		/**
		 * 字段描述：该条数据添加人员is  字段类型：character varying 长度：32
		 */
		public static final String column_createId = "createId";
		/**
		 * 字段描述：该条数据添加时间  字段类型：datetime 长度：0
		 */
		public static final String column_createDate = "createDate";
		/**
		 * 字段描述：该条数据更新人员id  字段类型：character varying 长度：100
		 */
		public static final String column_updateId = "updateId";
		/**
		 * 字段描述：该条数据更新时间  字段类型：datetime 长度：0
		 */
		public static final String column_updateDate = "updateDate";
	 
	 public float getStdWeight(String sex, int height, int age){
		 String sql = "select weight from sb_customer_std_weight where sex=? and height=? and min_age<=? and ?<=max_age";
		 StdWeightModel std = findFirst(sql, sex, height, age, age);
		 if(std==null)
		 {
			 return  0;
		 }else{
			 return std.getFloat("weight");
		 }
	}

}
